package com.thinkgem.jeesite.modules.task.common.taskjob;

import java.util.Date;

import com.thinkgem.jeesite.common.utils.CalendarUtils;
import com.thinkgem.jeesite.modules.employee.service.AttendanceRecordsService;
import com.thinkgem.jeesite.modules.employee.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import com.thinkgem.jeesite.modules.employee.entity.Employee;

/**
 * Created by xiaole.zheng on 2017/7/24.
 */
@Component("statisticalAttendanceTask")
public class StatisticalAttendanceTask {
    @Autowired
    private EmployeeService employeeService;
    @Autowired
    private AttendanceRecordsService attendanceRecordsService;

    /* @Scheduled(cron = "0 0 19 * * ?")*/
   //@Scheduled(fixedRate = 1000 * 60 * 5)
    public void doSomeThing(){
        //查出今天有排班的用户
        Date todayDate = CalendarUtils.diffDate(new Date(),1);
        System.out.println("sfafaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        List<Employee> employees = employeeService.findAllBySchedulingInformationAndDate(todayDate);
        for(Employee one:employees){
            try {
                attendanceRecordsService.genelUserAttendanceRecordsByCheckinout(one.getNumber(),todayDate);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
